<template>
    <Form
            :form-items="formItems"
    ></Form>
</template>

<script>
    import Form from '../../../../common-util/src/components/page/Form.vue'
    export default {
        components:{
            Form
        },
        data(){
            return {
                formItems:[
                    {
                        field: {
                            name: 'code'
                        },
                        element:{
                            label: '编号',
                            required: true
                        }
                    },
                    {
                        field: {
                            name: 'name'
                        },
                        element:{
                            label: '名称',
                            required: true
                        }
                    },
                    {
                        field: {
                            name: 'nameAlias'
                        },
                        element:{
                            label: '名称别名',
                            required: true
                        }
                    },
                    {
                        field: {
                            name: 'estateId',
                            value: this.$route.query.estateId || null,
                            estateId__label: this.$route.query.estateName || null,
                        },
                        element:{
                            label: '楼盘',
                            type: 'selectRemote',
                            selectRemote:{
                                url: this.$baseURL.house + '/house/estate/listPage',
                            },
                            required: true
                        }
                    },
                    {
                        field: {
                            name: 'buildingId',
                            value: this.$route.query.buildingId
                        },
                        element:{
                            label: '楼栋',
                            type: 'select',
                            select: {
                                url: (form)=> {
                                    if (!form.estateId) {
                                        return null
                                    }
                                    return this.$baseURL.house + '/house/building/list?estateId=' + form.estateId
                                }
                            },
                            disabled: (form)=> {
                                return !form.estateId
                            },
                            required: true
                        }
                    },
                    {
                        field: {
                            name: 'buildingUnitId'
                        },
                        element:{
                            label: '单元',
                            type: 'select',
                            select: {
                                url: (form)=> {
                                    if (!form.buildingId) {
                                        return null
                                    }
                                    return this.$baseURL.house + '/house/buildingunit/list?buildingId=' + form.buildingId
                                }
                            },
                            disabled: (form)=> {
                                return !form.buildingId
                            },
                        }
                    },
                    {
                        field: {
                            name: 'onFloor'
                        },
                        element:{
                            type: 'inputNumber',
                            label: '在第几层',
                            required: true
                        }
                    },
                    {
                        field: {
                            name: 'floorHeight'
                        },
                        element:{
                            type: 'inputNumber',
                            inputNumber: {
                                precision: 1,
                                step: 0.1
                            },
                            label: '层高',
                        }
                    },
                    {
                        field: {
                            name: 'estateApartmentLayoutId'
                        },
                        element:{
                            label: '户型',
                            type: 'select',
                            select: {
                                url: (form)=> {
                                    if (!form.estateId) {
                                        return null
                                    }
                                    return this.$baseURL.house + '/house/estateapartmentlayout/list?estateId=' + form.estateId
                                }
                            },
                            disabled: (form)=> {
                                return !form.estateId
                            },
                            required: true
                        }
                    },
                    {
                        field: {
                            name: 'usableArea'
                        },
                        element:{
                            type: 'inputNumber',
                            label: '套内面积(m²)',
                            required: true
                        }
                    },
                    {
                        field: {
                            name: 'shareArea'
                        },
                        element:{
                            type: 'inputNumber',
                            label: '分摊面积(m²)',
                            required: true
                        }
                    },
                    {
                        field: {
                            name: 'propertyTypeId'
                        },
                        element:{
                            label: '物业类型',
                            type: 'select',
                            select: {
                                url: this.$baseURL.house + '/house/propertytype/list'
                            },
                            required: true
                        }
                    },
                    {
                        element:{
                            type: 'button',
                            button:[
                                {
                                    action: 'submit',
                                    requestMethod:'post',
                                    url: this.$baseURL.house + '/house/buildingroom',
                                    label: '保存'
                                },
                                {
                                    action: 'reset',
                                    label: '重置',
                                    type: 'default'
                                }
                            ]
                        }
                    }
                ]
            }
        },
        methods:{
        }
    }
</script>

<style scoped>

</style>